let express = require('express');
let router = express.Router();

const userService = require('../service/userService');

/*
 * 用户使用工号密码登录接口
 */
router.post('/loginByWorkId', async function (req, res, next) {
    console.log('【请求到达的时间】', Date());
    let workId = req.body.workId;
    let password = req.body.password;
    if (!workId || !password) {
        res.status(400).json({ msg: "工号或密码为空", jwt: "" });
        return ;
    }
    let result = await userService.loginByWorkId(workId, password);
    res.status(result.success ? 200 : 400).json(result);
});

module.exports = router;
